import TaskStep from '@/components/taskStep.vue';
// 请求通用方法
import apiMixin from '@/mixin/apiMixin';
// 任务通用方法
import taskMixin from '@/mixin/taskMixin';


import keyup from '@/mixin/keyup';

export default {
    mixins: [apiMixin,taskMixin,keyup],
    data() {
        return {
            loading: false,
            showHandle: false,
            taskSteps: [],
            acceptLink: {},
            uploadBids: [],
            auditStatus: 1,
            specText: '',
            afirmBtnLoad: false,
            navIdList: [],
        }
    },
    mounted() {
        this.getTaskIdList();
        this.init();
    },
    methods: {
        init() {
            this.getAcceptDetailApi();
        },
        getAcceptDetailApi() {
            let acceptId = this.$route.query.acceptId;
            let _self = this;
            this.comResquest(this.request.getAcceptDetail,(res)=>{
                let { result } = res;
                _self.taskSteps = result.custom_steps;
                delete result.custom_steps;
                _self.acceptLink = result;
                console.log(res);
            },{
                acceptId: acceptId,
            });
        },
        handleAuditShow() {
            this.showHandle = !this.showHandle;
        },
        handleAuditAccept() {
            if (this.afirmBtnLoad) {
                return;
            }
            let auditStatus = this.auditStatus;
            let specText = this.specText;
            if (auditStatus == 0 && !specText) {
                this.$message.warning("请填写原因！");
                return;
            }
            this.postAuditAcceptApi(auditStatus,specText);
        },
        postAuditAcceptApi(auditStatus,specText) {
            let acceptId = this.$route.query.acceptId;
            let _self = this;
            this.comResquest(this.request.postAuditAccept,(res)=>{
                _self.handleAuditShow();
                _self.init();
                _self.$message.success("审核成功！");
            },{
                id: acceptId,
                ischeckok: auditStatus,
                comment: specText,
                load: "afirmBtnLoad"
            });
        },
        getTaskIdList() {
            this.getIdListApi(this.request.getAcceptList);
        },
        switchPage() {
            return new Promise((resolve,reject)=>{
                let _self = this;
                this.comResquest(this.request.getAcceptList,(res)=>{
                    resolve(res);
                },{
                    load: true,
                    page: this.listPage,
                    id_only: 1,
                    pagesize: 10
                })
            })
        },
        hanldeQuiteNav(type) {
            let acceptId = this.$route.query.acceptId;
            let _self = this;
            this.comQuiteNav(type,acceptId,(changeId)=>{
                _self.$router.push({ query: { acceptId: changeId,listPage: this.listPage } });
                _self.init();
            });
        }
    },
    components:{
        TaskStep
    },
}